package com.xintonghua.bussiness.util;

import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public abstract class AbstractFragmentPagerBaseAdapter extends FragmentPagerAdapter {

    List<Fragment> list;

    public AbstractFragmentPagerBaseAdapter(FragmentManager fm, List<Fragment> list) {
        super(fm);
        this.list = list;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return super.getPageTitle(position);
    }

    @Override
    public Fragment getItem(int position) {
        return getFragmentAtPosition(position);
    }

    public abstract Fragment getFragmentAtPosition(int position);

    @Override
    public int getCount() {
        if (MyUtils.isNullOrEmpty(list)) {
            return 0;
        }

        return list.size();
    }

    public List<Fragment> getList() {
        return list;
    }

    public void setList(List<Fragment> list) {
        this.list = list;
    }

}
